import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router'
import getLayoutRoutes from './autoRoute'
import guard from './guard'

const routes = [
  {
    path: '/',
    component: () => import('@/layout/home.vue'),
    //   redirect: { name: 'login' },
    //   children: [
    //     { path: 'login', name: 'login', component: () => import('@/views/login/index.vue') },
    //     { path: 'register', name: 'register', component: () => import('@/views/register/index.vue') },
    //   ],
    // },
    // {
    //   path: '/home',
    //   name: 'home',
    //   component: () => import('@/layout/home/index.vue'),
    //   redirect: { name: 'proj-list' },
    //   children: [
    //     {
    //       path: 'proj-list',
    //       name: 'proj-list',
    //       component: () => import('@/views/proj/list.vue'),
    //       children: [
    //         {
    //           path: 'zone-list/:id',
    //           name: 'zone-list',
    //           component: () => import('@/views/zone/list2.vue'),
    //           children: [
    //             { path: 'zone-info/:zoneId', name: 'zone-info', component: () => import('@/views/zone/info.vue') },
    //           ],
    //         },
    //       ],
    //     },
    //     {
    //       path: 'wire',
    //       name: 'wire',
    //       component: () => import('@/views/wire/list.vue'),
    //     },
    //     {
    //       path: 'image:id',
    //       name: 'image',
    //       component: () => import('@/views/image/index.vue'),
    //     },
    //   ],
  },
] as RouteRecordRaw[]

// console.table(getLayoutRoutes())

const router = createRouter({
  history: createWebHistory(),
  routes: [...routes, ...getLayoutRoutes()],
})

guard(router)

export default router
